package com.wngbms.aop._03;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

import java.util.Random;

@Aspect
public class AspectAnnotationConfig {

    @Pointcut("execution(public * *(..))")
    private void anyPublicMethod() {
    }

    @Before("anyPublicMethod()")
    public void beforeAnyPublicMethod2() {
        System.out.println("before2 any public... ");
    }

    @Before("anyPublicMethod()")
    public void beforeAnyPublicMethod() throws Throwable {

        System.out.println("before1 any public... ");
    }

    @AfterReturning("anyPublicMethod()")
    public void afterReturningAnyPublicMethod() {
        System.out.println("AfterReturning any public... ");
    }

    @AfterThrowing("anyPublicMethod()")
    public void afterThrowingAnyPublicMethod() {
        System.out.println("AfterThrowing any public... ");
    }

    @After("anyPublicMethod()")
    public void afterAnyPublicMethod() {
        System.out.println("After any public... ");
    }

    @Around("anyPublicMethod()")
    public Object aroundAnyPublicMethod(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("around any method");
        return pjp.proceed();
    }

}
